#!/usr/bin/env node

const fs=require('fs'),
      dirName=process.argv[2];
//空目录可以删除
//fs.rmdirSync(dirName);

//递归删除，删除非空目录

function deleteFolderRecursive(dirName) {
  if(fs.existsSync(dirName)){
    fs.readdirSync(dirName).forEach(function(file){
      var curPath = dirName + '/' + file;
      if(fs.statSync(curPath).isDirectory()){ // recurse
        deleteFolderRecursive(curPath);
      }else{ // delete file
        fs.unlinkSync(curPath);
      }
                                      
    });
    fs.rmdirSync(dirName);
  }
}
deleteFolderRecursive(dirName);

